#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#--------------
#奇数

def is_odd(n):
    return n % 2 == 1

list(filter(is_odd, [1, 2, 3, 4, 5]))

#--------------
#删除空项

def not_empty(s):
    return s and s.strip()
list(filter(not_empty, ['A', '', 'C', None, ' ']))

#--------------
#素数

#从3开始的无限序列生成器
def odd_iter():
    n = 1
    while True:
        n = n + 2
        yield n
#筛选函数
def not_div(n):
    return lambda x: x % n > 0

def primes():
    yield 2
    it = odd_iter()
    while True:
        n = next(it)
        yield n
        it = filter(not_div(n), it)

for i in primes():
    if i < 1000:
        print(i)
    else:
        break

#--------------    
#回数

n = int(input('input a num:'))

#过滤函数
def sotred_palindrome(num):
    n = str(num)
    return n == n[::-1]

#函数本体
def is_palindrome(m):
    #生成器
    ir = (i for i in range(m))
    
    l = list(filter(sotred_palindrome, ir))

    print(l)

is_palindrome(n)